package com.hst.capacity.infra.persistence.jpa.setting.station;

import com.hst.capacity.domain.model.entity.setting.station.ApplyStationEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface ApplyStationRepository extends JpaRepository<ApplyStationEntity, String> {

    /**
     * 通过地区CODE查找运营汽车站
     * @param code
     * @return
     */
    List<ApplyStationEntity> findByRegionCode(String code);

    ApplyStationEntity findByIdStation(String idStation);

    /**
     * 城际站取得
     * @param idStation
     * @return
     */
    @Query("SELECT t FROM ApplyStationEntity t WHERE t.idStation=:idStation AND t.stationType IN (0,1)")
    ApplyStationEntity findInterCityStationById(String idStation);

    /**
     * 市内站取得
     * @param idStation
     * @return
     */
    @Query("SELECT t FROM ApplyStationEntity t WHERE t.idStation=:idStation AND t.stationType IN (0,2)")
    ApplyStationEntity findInnerCityStationById(String idStation);

}
